Make a project and add MacTraps. Set Project Type to "Code Resource,"
and set the TYPE to "FKEY" and the ID number to 7 (or whatever╔).
I also suggest setting the "Attrs" to "purgeable" only, the NAME to
ToggleSndVol 3.1, and the File's type/creator to FKEY/MKEY. */
#define CANCEL_BUTTON_ID 8 /* id number of "Cancel" */
#define ABOUT_BUTTON_ID 9 /* id number of "?" */
#define NULL 0L /* duh */
#define SMALLBUTTONSIZE 15 /* how wide and tall a button is */
#define BUTTONMARGIN 3 /* number of pixels between buttons */
#define WINDOWWIDTH 222 /* dimensions of the window in pixels */
#define WINDOWHEIGHT 23
#define FKEY /* Comment that if you are testing. */
/* function prototypes... */
#pragma mark _prototypes
short DoIt(void); /* the main event loop */
void GetScreenBitsBounds(Rect *ScreenBitsBounds);
/* Get Screen dimensions */
short ModifierDown(void); /* is the option, shift, or cmd down? */
void SaveToPRAM(short newvol); /* write newvol to the control panel PRAM */
void SetTheVolume(short theVol); /* sets the speaker's volume */
void DoAbout(WindowPtr w, char *text);
/* extend the window, show info */
#ifdef FKEY
#include <SetUpA4.h>
#endif
main()
{
#ifdef FKEY
Handle h;
RememberA0();
SetUpA4();
asm
{ ;guarantee that INIT is locked even
_RecoverHandle ;if locked bit was not set with ResEdit
move.l a0,h ;save away handle to unlock later
_HLock ;handle is already in a0
}
InitCursor();
#else /* we're testing with an application. */
MaxApplZone();
InitGraf(&thePort);
InitFonts();
FlushEvents(everyEvent, 0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(0L);
InitCursor();
#endif
if (!DoIt())
{
SysBeep(3L); SysBeep(3L); /* we got an error. */
}
#ifdef FKEY
HUnlock(h);
/* DisposHandle(h); better let the system do that! */
RestoreA4();
#endif
return;
} /* main */
short DoIt(void)
{
Rect theRect;
WindowPtr theWind;
short sndVol;
short done = 0;
long dummy;
Rect itemRect, ScreenBitsBounds;
ControlHandle buttons[9], whichControl;
register short i;
Str255 title;
EventRecord theEvent;
char ch;
char text[] = "ToggleSndVol FKEY 3.1\r⌐1991 by Mike Gleason, NCEMRSoft.\r\rClicking or typing a number sets the sound volume in the Control Panel to that number. Hold"
"ing down the option key will NOT save the result to the PRAM (the change will only last for this boot). This FKEY is FREE :-) ";
/* This block of statements creates and "centers" (according to
Apple's liking) the little window's rectangle. */
theRect.top = theRect.left = 0;
theRect.right = WINDOWWIDTH;
theRect.bottom = WINDOWHEIGHT;
/* but first we need to get the screen dimensions. */